//LiuZh 2017-06-22

import React, {Component} from 'react';
import {
    View,
    Text,
    Button,
    StyleSheet,
} from 'react-native';

//导入SN用作顶部back等的导航
import Init from '../../../core/utils/date-tool';
import {
    StackNavigator,

} from 'react-navigation';

//主界面
import InitDB from '../../../core/database/init-db.js';
import LoginScene from '../../../core/scene/page.login';
import AboutUsScene from '../../../core/scene/page.about-us';
import ResetPwdScene from '../../../core/scene/page.reset-pwd';
import UserXieyiScene from '../../../core/scene/page.user-xieyi';
import ForgetPwdScene from '../../../core/scene/page.forget-password';
import HomeScene from './home/page.home';
import TouxiangScene from './mine/page.touxiang';
import SettingScene from './mine/setting/page.setting';
import AccountSafeScene from './mine/page.account-safe';
import UpdateMobileScene from './common/page.update-mobile';
import UpdateMobile1Scene from './common/page.update-bobile1';
import UpdateMobile2Scene from './common/page.update-mobile2';
import TongyongScene from './mine/page.tongyong.js';
import RegisterScene1 from '../../../core/scene/page.register';
import RegisterScene2 from './user/page.register2.js';
import PhotoDisplayScene from './common/page.photo-display';
import MainSkillDetailScene from './home/page.main.skill.detail';

import SetTextInput from '../../../core/component/comp.set-textInput.js';
import SetDataSource from '../../../core/component/comp.set-data-source.js';
import SetDate from '../../../core/component/comp.set-date.js';
import ShortVideo from './mine/page.short-video.js';

import Toolbar from '../../../core/component/comp.toolbar';
import Config from '../../../config';

/*初始化数据库 */
InitDB.init();

let currentUser = InitDB.getCurrentUser();
let initialRouteName;
if (currentUser) {//跳转到主页
    initialRouteName = 'Home';
} else {
    initialRouteName = 'Login';
}

if (Config.isDevMode) {
    initialRouteName = Config.initRouteName;
}

const AppNav = StackNavigator({
    Home: {
        screen: HomeScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>
            ),
            title: '主页',
        }),
    },
    Login: {
        screen: LoginScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>
            ),
            title: '登陆',
        }),
    },
    Register1: {
        screen: RegisterScene1,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}//是不是需要返回按钮
                    text={'用户注册'}/>//title内容
            ),
        }),
    },
    AboutUs: {
        screen: AboutUsScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}
                    textColor={'#FFF'}//title颜色
                    text={'关于我们'}/>//title内容
            ),
        }),
    },
    ResetPwd: {
        screen: ResetPwdScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    ForgetPwd: {
        screen: ForgetPwdScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}
                    text={'忘记密码'}/>//title内容
            ),
        }),
    },
    Register2: {
        screen: RegisterScene2,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}
                    text={'个人信息'}/>//title内容
            ),
        }),
    },
    UserXieyi: {
        screen: UserXieyiScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}
                    text={'用户需知'}/>//title内容
            ),
        }),
    },
    Touxiang: {
        screen: TouxiangScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>
            ),
        }),
    },
    Setting: {
        screen: SettingScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>
            ),
        }),
    },

    PhotoDisplay: {
        screen: PhotoDisplayScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>
            ),
        }),
    },
    AccountSafe: {
        screen: AccountSafeScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}
                    text={'账户与安全'}/>//title内容
            ),
        }),
    },
    UpdateMobile: {
        screen: UpdateMobileScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <Toolbar
                    navigation={navigation}
                    needBack={true}
                    text={'绑定手机号'}/>//title内容
            ),
        }),
    },
    UpdateMobile1: {
        screen: UpdateMobile1Scene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    UpdateMobile2: {
        screen: UpdateMobile2Scene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    Tongyong: {
        screen: TongyongScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    SetTextInput: {
        screen: SetTextInput,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    SetDataSource: {
        screen: SetDataSource,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    SetDate: {
        screen: SetDate,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    ShortVideo: {
        screen: ShortVideo,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    },
    MainSkillDetailScene:{
        screen:MainSkillDetailScene,
        navigationOptions: ({navigation}) => ({
            header: (
                <View/>//title内容
            ),
        }),
    }
}, {
    initialRouteParams: {
        title: '',
        someDate: '',
    },
    initialRouteName: initialRouteName,
    headerMode: 'screen' // <-- should allow you to change the styles of the header
})

export default AppNav;